//
//  WmcCancellationConfirmVC.swift
//  YPWatermarkCamera
//
//  Created by 马涛 on 2022/6/21.
//

import UIKit

// MARK: - 扩展WmcCancellationConfirmVC + WmcNavigatorProtocol

extension WmcCancellationConfirmVC: WmcNavigatorProtocol {
    static func navigationPaths() -> [WmcNavigatorManager.Path] {
        return [.cancellationConfirm]
    }

    static func willMakeNavigationVC(with parms: WmcNavigatorManager.Parms) -> UIViewController {
        let vc = WmcCancellationConfirmVC()
//        if let vm = parms.context as  {
//            <#code#>
//        }
        return vc
    }
}

// MARK: - 扩展WmcCancellationConfirmVC + WmcVMProtocol

extension WmcCancellationConfirmVC: WmcVMProtocol {
    typealias VMType = WmcCancellationConfirmVM
}

// MARK: - [WmcCancellationConfirmVC]

class WmcCancellationConfirmVC: WmcBaseVC {
    // Lifecycle

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "注销账号"
    }

    // Internal

    lazy var titleLabel: UILabel = {
        let view = UILabel()
        view.font = 16.yp.uiFont(weight: .bold)
        view.textColor = UIColor.wmc_blackH1_000000
        view.text = "注销协议已生效"
        return view
    }()

    lazy var contentLabel: UILabel = {
        let view = UILabel()
        view.font = 14.yp.uiFont(weight: .regular)
        view.textColor = UIColor.wmc_grayH5_606066
        view.numberOfLines = 0
        view.text = "您的注销申请已提交，可在7日内在登录账号时选择恢复账号或联系客服400-838-1888申请恢复账号，7日后将永久删除您的账号及账号内绑定的数据。"
        return view
    }()

    lazy var warningLabel: UILabel = {
        let view = UILabel()
        view.font = 14.yp.uiFont(weight: .regular)
        view.textColor = UIColor.wmc_red_F54A45
        view.numberOfLines = 0
        view.text = "*注意：如果您之前有发布过招工信息或找活名片等操作，在7天内仍可能有工友与您取得联系，并非注销失败。"
        return view
    }()

    lazy var finishButton: UIButton = {
        let view = UIButton()
        view.setTitle("完成", for: .normal)
        view.setTitleColor(UIColor.wmc_white_FFFFFF, for: .normal)
        view.backgroundColor = UIColor.wmc_mainTheme
        view.layer.cornerRadius = 3
        view.clipsToBounds = true
        return view
    }()
    
    override func backAction() {
        WmcLoginManager.logout()
        WmcHomeVC.PopTooRoot()
    }

    override func makeUI() {
        
        makeNavView(showShadow: false)

        addSubview(titleLabel)
        addSubview(contentLabel)
        addSubview(warningLabel)
        addSubview(finishButton)

        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(self.navView.snp.bottom)
            make.left.equalTo(13)
        }
        contentLabel.snp.makeConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom).offset(12)
            make.left.equalTo(13)
            make.right.equalTo(-13)
        }
        warningLabel.snp.makeConstraints { make in
            make.top.equalTo(contentLabel.snp.bottom).offset(10)
            make.left.equalTo(13)
            make.right.equalTo(-13)
        }
        finishButton.snp.makeConstraints { make in
            make.top.equalTo(warningLabel.snp.bottom).offset(43)
            make.left.equalTo(13)
            make.right.equalTo(-13)
            make.height.equalTo(42)
        }
    }

    override func bindViewAction() {
        finishButton.yp.addEvent() { [weak self] _ in
            guard let weakSelf = self else { return }
            WmcLogManager.Log("完成")
            WmcLoginManager.logout()
            WmcHomeVC.PopTooRoot()
        }
    }
}
